﻿<!-- 
    Copyright (c) 2011 Microsoft Corporation.  All rights reserved.
    Use of this sample source code is subject to the terms of the Microsoft license 
    agreement under which you licensed this sample source code and is provided AS-IS.
    If you did not accept the terms of the license agreement, you are not authorized 
    to use this sample source code.  For the terms of the license, please see the 
    license agreement between you and Microsoft.
    
    To see all Code Samples for Windows Phone, visit http://go.microsoft.com/fwlink/?LinkID=219604
-->
<phone:PhoneApplicationPage
    xmlns:UI="clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI" 
    
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Model="clr-namespace:TagCloudNewsLibrary.Model;assembly=TagCloudNewsLibrary" 
    xmlns:local="clr-namespace:TagCloudNews"
    x:Class="TagCloudNews.StoriesPage"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
    shell:SystemTray.IsVisible="False">


    <phone:PhoneApplicationPage.Resources>
        <ResourceDictionary>
            <local:DebuggingConverter x:Key="converter" />
        </ResourceDictionary>
    </phone:PhoneApplicationPage.Resources>


    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="LikeButton" IconUri="/Resources/Icons/faves.png" Text="Like it" Click="LikeButton_Click"/>
            <shell:ApplicationBarIconButton x:Name="ReadAllButton" IconUri="/Resources/Icons/check.png" Text="Read All" Click="ReadAllButton_Click"/>
            <shell:ApplicationBarIconButton x:Name="PinButton2" IconUri="/Resources/Icons/pin.png" Text="Pin to Start" Click="PinButton_Click"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem x:Name="PinButton" Text="Pin To Start Page" Click="PinButton_Click" />
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

    <phone:PhoneApplicationPage.DataContext>
        <Model:StoriesModel/>
    </phone:PhoneApplicationPage.DataContext>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="{StaticResource AppName}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Name="PageTitle"  Text="{Binding Tag}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
            <TextBlock x:Name="LikeStatus" Text="{Binding LikedText}" Margin="9,0,-1,0"  Height="40" TextAlignment="Right" Foreground="{Binding LikedTagColour}" />
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <StackPanel Grid.Row="1">
            <ListBox  HorizontalContentAlignment="Stretch" ItemsSource="{Binding Stories}" x:Name="feedListBox" ScrollViewer.VerticalScrollBarVisibility="Auto" SelectionChanged="feedListBox_SelectionChanged" Height="450" >
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="32"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            
                            <Image Grid.Column="0" x:Name="Icon" Height="32" Width="32" Stretch="Fill"  Source="{Binding Icon}" Visibility="Visible"  />
                            <TextBlock Grid.Column="1" x:Name="feedSummary" Style="{StaticResource PhoneTextTitle2Style}" TextWrapping="Wrap" Margin="12,12,12,12" Text="{Binding Title}" Foreground="{Binding StoryColour}" />
                            
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            
            <UI:AdControl IsAutoCollapseEnabled="True"  x:Name="AdUnit" AdUnitId="{Binding Source={StaticResource AdId}}" ApplicationId="{Binding Source={StaticResource AdAppId}}" Margin="0,0,0,0" RenderTransformOrigin="0.5,0.5" Height="80" >
                <UI:AdControl.RenderTransform>
                    <CompositeTransform ScaleY="-1"/>
                </UI:AdControl.RenderTransform>
            </UI:AdControl>
        </StackPanel>
    </Grid>

</phone:PhoneApplicationPage>
